package com.xbn.xbnmall.search.controller;

import com.xbn.xbnmall.search.service.MallSearchService;
import com.xbn.xbnmall.search.vo.SearchParam;
import com.xbn.xbnmall.search.vo.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @author XBN
 * @date 2020/8/6 14:25
 * @email 78742541@qq.com
 */
@Controller
public class SearchController {
    @Autowired
    MallSearchService mallSearchService;
   @GetMapping("list.html")
    public String listPage(SearchParam searchParam, Model model, HttpServletRequest request){
       searchParam.set_queryString(request.getQueryString());
       SearchResult result=  mallSearchService.search(searchParam);
       model.addAttribute("result",result);
       return "list";
   }
}
